package com.ghh.app.monsterrush.weapons.state;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.ghh.app.monsterrush.StateAction;
import com.ghh.app.monsterrush.WeaponActor;

public class StandByState implements StateAction {
	private WeaponActor		weapon;
	private TextureRegion	textureRegion;
	private Animation		animation;
	private float			stateTime	= 0f;
	
	public StandByState(WeaponActor weapon, Texture texture) {
		this.weapon = weapon;
		this.textureRegion = new TextureRegion(texture);
	}
	
	public StandByState(WeaponActor weapon, TextureRegion[] frames, float duration) {
		this.weapon = weapon;
		animation = new Animation(duration, frames);
	}
	
	@Override
	public void start() {
		stateTime = 0f;
	}

	@Override
	public void act(float deltaTime) {
		stateTime += deltaTime;
	}

	@Override
	public void draw(SpriteBatch batch) {
		TextureRegion frame = null;
		if (textureRegion != null) {
			frame = textureRegion;
		} else {
			frame = animation.getKeyFrame(stateTime);
		}
		weapon.drawFrame(batch, frame);
	}

}
